package me.zingon.doc.controller;

import me.zingon.doc.cache.TestCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by zhidi on 2018-3-23.
 */
@RestController
public class CacheController {

    @Autowired
    TestCache testCache;

    @GetMapping("/set/{key}/{value}")
    public void set(@PathVariable("key")String key, @PathVariable("value")String value){
        testCache.set(key,value);
    }

    @GetMapping("/get/{key}")
    public Object get(@PathVariable("key")String key){
        return testCache.get(key);
    }

    @GetMapping("/setnx/{key}/{value}")
    public Object setnx(@PathVariable("key")String key,@PathVariable("value")String value){
        return testCache.setnx(key,value);
    }

    @GetMapping("/pexpire/{key}/{time}")
    public Object pexpire(@PathVariable("key")String key,@PathVariable("time")Long time){
        return testCache.pexpire(key,time);
    }

    @GetMapping("/rm/{key}")
    public void rm(@PathVariable("key")String key){
        testCache.rm(key);
    }

    @GetMapping("/list/{key}")
    public Object list(@PathVariable("key")String key){
        return testCache.list(key);
    }
}
